# 查找关键字文件

from sys import argv
from os import path, listdir
# 正则表达式模块
import re

class FindFile(object):
    keywords = ''
    def __init__(self):
        self.getArgv()
    # 获取argv参数
    def getArgv(self):
        if len(argv) <= 1:
            print('argv error')
        else:
            self.keywords = argv[1]
    # 查找当前目录
    def find(self, relPath):
        def readDir(dirPath):
            for item in listdir(dirPath):
                newDir = path.join(dirPath, item)
                if path.isdir(newDir):
                    readDir(newDir)
                else:
                    absDirPath = path.abspath(newDir)
                    if re.search(self.keywords, item) != None:
                        print(absDirPath)
        readDir(relPath)

if __name__ == "__main__":
    finder = FindFile()
    # 这里指向的是执行py命令的文件夹目录
    finder.find('.')
    # print(path.isdir(path.abspath('./module/__pycache__')))